
<div class="model_actions_toolbar">
    <?php $this->widget('backend.components.ModelActions'); ?>
</div>

<link href="<?php echo Yii::app()->baseUrl; ?>/assets/backend/treeTable/stylesheets/jquery.treeTable.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/assets/backend/treeTable/javascripts/jquery.treeTable.min.js"></script>
<script type="text/javascript">  
$(document).ready(function()  {
//    $(".example").treeTable({expandable: false});
//    $(".example").attrs('display', 'none');
    $("#tbl_c").treeTable({expandable: false});
});  
</script>
<table class="example" id="dnd-example" style="display: none;">
  <caption>Example 3: Dragging and dropping example.</caption>
  <thead>
    <tr>
      <th>Title</th>
      <th>Size</th>
      <th>Kind</th>
    </tr>
  </thead>
  <tbody>
    <tr id="node-20">
      <td><span class="file">CHANGELOG</span></td>
      <td>4 KB</td>
      <td>Plain text</td>
    </tr>

    <tr id="node-1">
      <td><span class="folder">doc</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    <tr id="node-2" class="child-of-node-1">
      <td><span class="folder">images</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    

    <tr id="node-9" class="child-of-node-2">
      <td><span class="file">folder.png</span></td>
      <td>4 KB</td>
      <td>Portable Network Graphics image</td>
    </tr>

    <tr id="node-10" class="child-of-node-2">
      <td><span class="file">page_white_text.png</span></td>
      <td>4 KB</td>
      <td>Portable Network Graphics image</td>
    </tr>

    <tr id="node-3" class="child-of-node-1">
      <td><span class="file">index.html</span></td>
      <td>4 KB</td>
      <td>HTML document</td>
    </tr>

    <tr id="node-4" class="child-of-node-1">
      <td><span class="folder">javascripts</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    <tr id="node-5" class="child-of-node-4">
      <td><span class="file">jquery.js</span></td>
      <td>56 KB</td>
      <td>JavaScript source</td>
    </tr>

    <tr id="node-6" class="child-of-node-1">
      <td><span class="folder">stylesheets</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    <tr id="node-7" class="child-of-node-6">
      <td><span class="file">master.css</span></td>
      <td>4 KB</td>
      <td>CSS style sheet</td>
    </tr>

    <tr id="node-14">
      <td><span class="file">MIT-LICENSE</span></td>
      <td>4 KB</td>
      <td>Plain text</td>
    </tr>

    <tr id="node-18">
      <td><span class="file">README.markdown</span></td>
      <td>4 KB</td>
      <td>Markdown document</td>
    </tr>

    <tr id="node-11">
      <td><span class="folder">src</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    <tr id="node-12" class="child-of-node-11">
      <td><span class="folder">images</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    <tr id="node-15" class="child-of-node-12">
      <td><span class="file">bullet_toggle_minus.png</span></td>
      <td>4 KB</td>
      <td>Portable Network Graphics image</td>
    </tr>

    <tr id="node-16" class="child-of-node-12">
      <td><span class="file">bullet_toggle_plus.png</span></td>
      <td>4 KB</td>
      <td>Portable Network Graphics image</td>
    </tr>

    <tr id="node-13" class="child-of-node-11">
      <td><span class="folder">stylesheets</span></td>
      <td>--</td>
      <td>Folder</td>
    </tr>

    <tr id="node-17" class="child-of-node-13">
      <td><span class="file">jquery.treeTable.css</span></td>
      <td>4 KB</td>
      <td>CSS style sheet</td>
    </tr>

    <tr id="node-19" class="child-of-node-11">
      <td><span class="file">jquery.treeTable.js</span></td>
      <td>8 KB</td>
      <td>JavaScript source</td>
    </tr>

  </tbody>
</table>
<?php
class hiscaler {

}
?>
<?php
echo CHtml::beginForm(array('MultiLevelCategories/delete'), 'post', array(
    'onSubmit' => "return fnOnSubmitDeleteConfirm('" . CHtml::encode(Yii::t('jsmsg', 'confirm_delete')) . '\',\'' . Yii::t('jsmsg', 'unselect_tips') . "');"
));
?>
<table id="tbl_c" border="0" width="100%" cellpadding="0" cellspacing="0" class="datas_grid">
    <thead>
        <tr>
            <th><input type="checkbox" id="checkallboxs" onclick="$('input[name=\'delete[]\']').attr('checked', this.checked);" /></th>
            <th><?php echo $sort->link('order_pos'); ?></th>
            <th><?php echo $sort->link('name'); ?></th>
            <th><?php echo $sort->link('icon_saved_path'); ?></th>
            <th><?php echo $sort->link('created'); ?></th>
            <th><?php echo $sort->link('updated'); ?></th>
            <th></th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td>
                <?php
                echo CHtml::hiddenField('parent', $parent);
                echo CHtml::imageButton(Yii::app()->baseUrl . '/assets/backend/images/action_delete.png');
                ?>
            </td>
            <td colspan="6">
                <?php $this->widget('CLinkPager', array('pages' => $pages)); ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
        <?php foreach($roots as $n => $root): ?>
        <tr id="node-<?php echo $n; ?>" class="child-of-node-<?php echo $root->parent_id; ?>">
            <td class="sn_and_checkbox">
                <input type="checkbox" name="delete[]" value="<?php echo $root->id; ?>">
                <?php echo sprintf("%02d", ++$n + $pages->getCurrentPage() * $pages->getPagesize()); ?>
            </td>
            <td class="order_pos"><input type="text" id="order_pos_<?php echo $root->id; ?>" value="<?php echo $root->order_pos; ?>" class="numerical" onchange="fnChangeOrderPos(<?php echo $root->id; ?>)" /></td>
            <td>
                <span class="id">#<?php echo $root->id; ?></span>
                <font style="font-size: 1.2em; font-weight: bold; color: #ff0000; "><?php echo CHtml::encode($root->name); ?></font>
            </td>
            <td class="brand_icon"><?php echo $root->iconImageTag; ?></td>
            <td class="date"><?php echo date('Y-m-d', $root->created); ?></td>
            <td class="date"><?php echo $root->updatedFormatted; ?></td>
            <td class="action">
                <?php
                echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/assets/backend/images/btn_edit.png'),
                    array('update', 'id' => $root->id)
                    );
                ?>
            </td>
        </tr>
        <?php
        endforeach;
        ?>
    </tbody>
</table>
<?php echo CHtml::endForm(); ?>

<script type="text/javascript">
    function fnChangeOrderPos(element_id) {
        var value = $('#order_pos_' + element_id).val();
        $.ajax({
            type: "POST",
            url: "<?php echo $this->createUrl('posts/changeOrderPos') ?>",
            data: "id=" + element_id + "&value=" + value,
            beforeSend: function() {
                $('#order_pos_' + element_id).removeClass('numerical');
                $('#order_pos_' + element_id).addClass('numerical_is_changed');
            },
            success: function(result){
                if (parseInt(result) == 0) {
                    alert('Error: ' + result);
                }
            },
            error: function(msg) {
                alert(msg);
            }
        });
    }
</script>